<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="../node_modules/weui/dist/style/weui.min.css">
    <link rel="stylesheet" href="./css/style.css">
    <title>个人中心</title>
</head>
<body ontouchstart>
    <div class="page" id="modify-psd">
        <div class="page_hd">
            <h1 class="page_hd_txt">修改密码</h1>
        </div>
        <div class="page_bd">
            <div class="weui-cells weui-cells_form page-form">
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label for="" class="weui-label">原密码</label>
                    </div>
                    <div class="weui-cell__bd weui-cell__primary">
                        <input type="password" name="password" class="weui-input" required pattern="[\w]{6,}" emptyTips="请输入原密码" notmatchtips="密码至少6位" placeholder="请输入原密码">
                    </div>
                    <div class="weui-cell__ft">
                        <i class="weui-icon-warn"></i>
                    </div>
                </div>
                <div class="weui-cell weui-cell-warn">
                    <div class="weui-cell__hd">
                        <label for="" class="weui-label">新密码</label>
                    </div>
                    <div class="weui-cell__bd weui-cell__primary">
                        <input type="password" name="password" class="weui-input" required pattern="[\w]{6,}" emptyTips="请输入新密码" notmatchtips="密码至少6位" placeholder="请输入新密码">
                    </div>
                    <div class="weui-cell_ft">
                        <i class="weui-icon-warn"></i>
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label for="" class="weui-label">确认新密码</label>
                    </div>
                    <div class="weui-cell__bd weui-cell__primary">
                        <input type="password" name="password" class="weui-input" required pattern="[\w]{6,}" emptyTips="请再次输入新密码" notmatchtips="密码至少6位" placeholder="请再次输入新密码">
                    </div>
                    <div class="weui-cell_ft">
                        <i class="weui-icon-warn"></i>
                    </div>
                </div>
            </div>
            <div class="weui-btn-area">
                <a class="weui-btn weui-btn_primary" href="javascript:login();">确认</a>
            </div>
        </div>
    </div>
    <script src="../node_modules/weui/dist/example/zepto.min.js"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.1/weui.min.js"></script>
    <script>
        weui.form.checkIfBlur('#modify-psd');

        function login(){
            weui.form.validate('#modify-psd', function (error) {
                console.log(error);
                if (error==null) {
                    weui.topTips('原密码不正确',2000);
                    return ;
                }
                if (!error) {
                    var loading = weui.loading('修改中...');
                    setTimeout(function () {
                        loading.hide();
                        weui.toast('修改成功', 2000);
                    }, 1500);
                }
                // return true; // 当return true时，不会显示错误
            }, {
                regexp: {
                    
                }
            });
        }
    </script>
</body>
</html>